package com.qifenqian.turbot.net

import com.qifenqian.turbot.module.entity.response.*
import com.qifenqian.turbot.module.entity.response.dish.CategoryEntity
import com.qifenqian.turbot.module.entity.response.dish.DishEntity
import com.qifenqian.turbot.module.entity.response.marketing.*
import com.qifenqian.turbot.module.entity.response.restaurant.*
import com.qifenqian.turbot.module.entity.response.statistic.SoldDishEntity
import com.qifenqian.turbot.module.entity.response.statistic.StatisticsEntity
import io.reactivex.Observable
import okhttp3.RequestBody
import retrofit2.http.*

/**
 * @author H
 * @createTime 2018/12/27 11:22
 * @description
 * @see [NetService]
 * @since
 */
interface TurbotService {

    /**
     * @createDate 2018/12/12 16:16
     * @description 登录注册等接口
     */
    interface LoginEtcService {

        /**
         * 2.1/2.2 登录
         * 2001
         * /userLogin/login
         * code: 0：成功；1：密码错误；2：验证码错误；3：手机号未注册；999：系统异常
         */
        @POST("turbot/app/{id}")
        fun login(@Body body: RequestBody, @Path("id") id: Int = 2001): Observable<BaseEntity<LoginEntity>>

        /**
         * 2.3 发送验证码
         * 2002
         * /userLogin/sendSmsCode
         * 需要修正
         */
        @POST("turbot/app/{id}")
        fun sendSmsCode(@Body body: RequestBody, @Path("id") id: Int = 2002): Observable<BaseEntity<Nothing>>

        /**
         * 2.5 忘记密码
         * 2003
         * /user/resetPassword
         * 0：成功；2：验证码错误；3：手机号未注册，999：系统异常
         */
        @POST("turbot/app/{id}")
        fun resetPassword(@Body body: RequestBody, @Path("id") id: Int = 2003): Observable<BaseEntity<Nothing>>

        /**
         * 2.4 退出
         * 2004
         * /userLogin/logout
         */
        @POST("turbot/app/{id}")
        fun logout(@Body body: RequestBody, @Path("id") id: Int = 2004): Observable<BaseEntity<Nothing>>

        /**
         * 3.1 注册
         * 2005
         * /user/register
         * 0：成功；2：验证码错误；4：手机号已注册；999：系统异常
         */
        @POST("turbot/app/{id}")
        fun register(@Body body: RequestBody, @Path("id") id: Int = 2005): Observable<BaseEntity<LoginEntity>>

        /**
         * 3.2 资质认证1
         * 2006
         * /qualityCertification/user/First
         */
        @POST("turbot/app/{id}")
        fun qualityCertificationFirst(@Body body: RequestBody, @Path("id") id: Int = 2006): Observable<BaseEntity<Nothing>>

        /**
         * 3.3 资质认证2
         * 2006
         * qualityCertification/user/Second
         */
        @POST("turbot/app/{id}")
        fun qualityCertificationSecond(@Body body: RequestBody, @Path("id") id: Int = 2006): Observable<BaseEntity<Nothing>>

        /**
         * 7.5.1.1 修改手机号
         * /user/changePhone
         * 6501
         */
        @POST("turbot/app/{id}")
        fun modifyPhone(@Body body: RequestBody, @Path("id") id: Int = 6501): Observable<BaseEntity<Nothing>>

        /**
         * 7.5.1.2 修改登录密码
         * /user/changePassword
         * 6502
         */
        @POST("turbot/app/{id}")
        fun modifyPassword(@Body body: RequestBody, @Path("id") id: Int = 6502): Observable<BaseEntity<Nothing>>
    }

    /**
     * @createTime 2018/12/25 16:19
     * @description 商铺信息
     */
    interface RestaurantService {

        /**
         * 7.1.1 商铺信息
         * /restaurant/getBasicInfo/{restaurantId}
         * 6001
         */
        @GET("turbot/app/{id}")
        fun getRestaurantInfo(@Path("id") id: Int = 6001, @Query("restaurantId") restaurantId: Int): Observable<BaseEntity<RestaurantEntity>>

        /**
         * 7.1.2 更改商铺简称
         * /restaurant/editInfo/{restaurantId}
         * 6002
         */
        @POST("turbot/app/{id}")
        fun editShortName(@Path("id") id: Int = 6002, @Body body: RequestBody): Observable<BaseEntity<Nothing>>

        /**
         * 7.1.3.1 获得餐厅照片
         * /restaurant/getPhotoList/{restaurantId}
         * 6003
         */
        @GET("turbot/app/{id}")
        fun getPhotoList(@Path("id") id: Int = 6003, @Query("restaurantId") restaurantId: Int): Observable<BaseEntity<List<RestaurantPhotoEntity>>>

        /**
         * 7.1.3.2 保存餐厅照片
         * /restaurant/savePhotoList
         * 6004
         */
        @POST("turbot/app/{id}")
        fun savePhotoList(@Body body: RequestBody, @Path("id") id: Int = 6004): Observable<BaseEntity<Nothing>>

        /**
         * 7.1.4.1 获取菜系列表
         * /restaurant/getCuisineList/{restaurantId}
         * 6005
         */
        @GET("turbot/app/{id}")
        fun getCuisineList(@Path("id") id: Int = 6005): Observable<BaseEntity<List<CuisineEntity>>>

        /**
         * 7.1.4.2 选择菜系
         * /restaurant/editInfo/{restaurantId}
         * 6002
         */
        @POST("turbot/app/{id}")
        fun chooseCuisine(@Body body: RequestBody, @Path("id") id: Int = 6002): Observable<BaseEntity<Nothing>>

        /**
         * 7.1.5.1 获取餐桌信息
         * /restaurant/getTableInfo/{restaurantId}
         * 6006
         */
        @GET("turbot/app/{id}")
        fun getTableInfo(@Path("id") id: Int = 6006, @Query("restaurantId") restaurantId: Int): Observable<BaseEntity<RestaurantTableEntity>>

        /**
         * 2019/1/9 16:25 (迟早废弃,合并到6007)
         * 7.1.5.2 删除餐桌
         * restaurant/deleteTable
         * 6013
         */
        @POST("turbot/app/{id}")
        fun deleteTableInfo(@Body body: RequestBody, @Path("id") id: Int = 6013): Observable<BaseEntity<Nothing>>

        /**
         * 7.1.5.3 保存餐桌信息
         * /restaurant/saveTableInfo/{restaurantId}
         * 6007
         */
        @POST("turbot/app/{id}")
        fun saveTableInfo(@Body body: RequestBody, @Path("id") id: Int = 6007): Observable<BaseEntity<Nothing>>

        /**
         * 7.1.6 在线选座开关
         * /restaurant/editInfo/{restaurantId}
         * 6002
         */
        @POST("turbot/app/{id}")
        fun setAvailableChooseSeat(@Body body: RequestBody, @Path("id") id: Int = 6002): Observable<BaseEntity<Nothing>>

        /**
         * 7.1.7 修改餐厅电话
         * /restaurant/editInfo/{restaurantId}
         * 6002
         */
        @POST("turbot/app/{id}")
        fun changeRestaurantPhone(@Body body: RequestBody, @Path("id") id: Int = 6002): Observable<BaseEntity<Nothing>>

        /**
         * 7.1.8 修改营业时间
         * /restaurant/editInfo/{restaurantId}
         * 6002
         */
        @POST("turbot/app/{id}")
        fun changeBusinessTime(@Body body: RequestBody, @Path("id") id: Int = 6002): Observable<BaseEntity<Nothing>>

        /**
         * 7.1.9 修改经营地址
         * /restaurant/editInfo/{restaurantId}
         * 6002
         */
        @POST("turbot/app/{id}")
        fun changeAddress(@Body body: RequestBody, @Path("id") id: Int = 6002): Observable<BaseEntity<Nothing>>

        /**
         * 7.1.10 设置人均消费金额
         * /restaurant/editInfo/{restaurantId}
         * 6002
         */
        @POST("turbot/app/{id}")
        fun changePersonConsume(@Body body: RequestBody, @Path("id") id: Int = 6002): Observable<BaseEntity<Nothing>>

        /**
         * 7.1.11.1 获取全部餐厅服务
         * /restaurant/getServiceList/{restaurantId}
         * 6008
         */
        @GET("turbot/app/{id}")
        fun getServiceList(@Path("id") id: Int = 6008, @Query("restaurantId") restaurantId: Int): Observable<BaseEntity<List<RestaurantServiceEntity>>>

        /**
         * 7.1.11.2 添加餐厅服务
         * 返回serviceId
         * /restaurant/addService/{restaurantId}
         * 6009
         */
        @POST("turbot/app/{id}")
        fun addService(@Body body: RequestBody, @Path("id") id: Int = 6009): Observable<BaseEntity<RestaurantServiceEntity>>

        /**
         * 7.1.11.3 删除餐厅服务
         * /restaurant/deleteService/{id}
         * 6010
         */
        @POST("turbot/app/{id}")
        fun deleteService(@Path("id") id: Int = 6010, @Body body: RequestBody): Observable<BaseEntity<Nothing>>

        /**
         * 7.1.11.4 选择餐厅服务
         * /restaurant/chooseService/{restaurantId}
         * 6011
         */
        @POST("turbot/app/{id}")
        fun chooseService(@Body body: RequestBody, @Path("id") id: Int = 6011): Observable<BaseEntity<RestaurantServiceEntity>>

        /**
         * 7.1.12.1 获取餐厅介绍
         * 应该是在获取餐厅全部信息的接口获得
         * /restaurant/findRestaurantIntroduction/{restaurantId}
         * 6012
         */
        @POST("turbot/app/{id}")
        fun getRestaurantIntroduction(@Path("id") id: Int = 6012, @Body body: RequestBody): Observable<BaseEntity<RestaurantEntity>>

        /**
         * 7.1.12.2 设置餐厅介绍
         * /restaurant/editInfo/{restaurantId}
         * 6002
         */
        @POST("turbot/app/{id}")
        fun changeRestaurantIntroduction(@Body body: RequestBody, @Path("id") id: Int = 6002): Observable<BaseEntity<Nothing>>

    }

    /**
     * @createTime 2018/12/27 11:22
     * @description 菜品相关
     * @since
     */
    interface DishService {

        /**
         * 7.2.1 获取菜品类别列表
         * /menu/getDishTypeList/{restaurantId}
         * 6101
         */
        @GET("turbot/app/{id}")
        fun getCategoryList(@Path("id") id: Int = 6101, @Query("restaurantId") restaurantId: Int): Observable<BaseEntity<List<CategoryEntity>>>

        /**
         * 7.2.2 获取菜品列表
         * /menu/getDishList/{restaurantId}
         * 6102
         */
        @GET("turbot/app/{id}")
        fun getAllDishList(
                @Path("id") id: Int = 6102,
                @Query("restaurantId") restaurantId: Int,
                @Query("pageNo") pageNo: Int = 0,
                @Query("pageSize") pageSize: Int = 10000
                          )
                : Observable<BaseEntity<List<DishEntity>>>

        /**
         * 7.2.3 按照菜品类型获得菜品列表
         * /menu/findDisheListByDishTypeId/{id}
         * 6103
         */
//        @Deprecated("没有用到")
//        @GET("")
//        fun getTargetDishList(@Path("id") id: Int): Observable<BaseEntity<List<DishEntity>>>

        /**
         * 7.2.4 添加菜品
         * /menu/addDish/{restaurantId}
         * 6104
         */
        @POST("turbot/app/{id}")
        fun addDish(@Body body: RequestBody, @Path("id") id: Int = 6104): Observable<BaseEntity<DishEntity>>

        /**
         * 7.2.5.1 获取菜品详情
         * /menu/getDishDetail/{dishId}
         * 6105
         */
        @GET("turbot/app/{id}")
        fun getDishDetail(@Path("id") id: Int = 6105, @Query("dishId") dishId: Int): Observable<BaseEntity<DishEntity>>

        /**
         * 7.2.5.2 编辑菜品详情
         * /menu/editDishDetail/{dishId}
         * 6106
         */
        @POST("turbot/app/{id}")
        fun editDish(@Body body: RequestBody, @Path("id") id: Int = 6106): Observable<BaseEntity<Nothing>>

        /**
         * 7.2.5.3 删除菜品
         * /menu/deleteDish/{dishId}
         * 6107
         */
        @POST("turbot/app/{id}")
        fun deleteDish(@Path("id") id: Int = 6107, @Body body: RequestBody): Observable<BaseEntity<Nothing>>
        /**
         * 7.2.6 调整菜品类型顺序
         */
//        @POST("/menu/modifyDishTypeOrder")
//        fun modifyDishTypeOrder(@Field("dishTypeName") dishTypeName: String, @Field("id") id: Int, @Path("id") id: Int = 2001): Observable<BaseEntity<Nothing>>

        /**
         * 7.2.7 添加菜品类型
         * /menu/addDishType/{restaurantId}
         * 6109
         */
        @POST("turbot/app/{id}")
        fun addCategory(@Body body: RequestBody, @Path("id") id: Int = 6109): Observable<BaseEntity<CategoryEntity>>

        /**
         * 7.2.8 编辑菜品类型
         * /menu/editDishType/{id}
         * 6110
         */
        @POST("turbot/app/{id}")
        fun editCategory(@Body body: RequestBody, @Path("id") id: Int = 6110): Observable<BaseEntity<Nothing>>

        /**
         * 7.2.9 删除菜品类型
         * /menu/deleteDishType/{id}
         * 6111
         */
        @POST("turbot/app/{id}")
        fun deleteCategory(@Path("id") id: Int = 6111, @Body body: RequestBody): Observable<BaseEntity<Nothing>>

        /**
         * 7.2.10 保存菜品类型
         * /menu/saveDishTypeList
         * 6112
         */
        @POST("turbot/app/{id}")
        fun saveCategory(@Body body: RequestBody, @Path("id") id: Int = 6112): Observable<BaseEntity<Nothing>>

    }

    interface CommentService {
        /**
         * 7.3.1 评论列表
         * /comment/getCommentList/{restaurantId}
         * 6301
         */
        @GET("turbot/app/{id}")
        fun getCommentList(
                @Path("id") id: Int = 6301, @Query("restaurantId") restaurantId: Int, @Query(
                        "pageNo"
                                                                                            ) pageNo: Int, @Query(
                        "pageSize"
                                                                                                                 ) pageSize: Int
                          ): Observable<BaseEntity<List<CommentEntity>>>

        /**
         * 7.3.2 回复评论
         * /comment/reply/{commentId}
         * 6302
         */
        @POST("turbot/app/{id}")
        fun reply(@Body body: RequestBody, @Path("id") id: Int = 6302): Observable<BaseEntity<Nothing>>

        /**
         * 7.3.3 删除评论
         * /comment/deleteReply/{replyId}
         */
    }

    interface StaffService {


        /**
         * 7.4.1 获取店员列表
         * /user/getUserList/{restaurantId}
         * 6401
         */
        @GET("turbot/app/{id}")
        fun getStaffList(@Path("id") id: Int = 6401, @Query("restaurantId") restaurantId: Int): Observable<BaseEntity<List<StaffEntity>>>

        /**
         * 7.4.2 新增店员
         * /user/addUser/{restaurantId}
         * 6402
         */
        @POST("turbot/app/{id}")
        fun addStaff(@Body body: RequestBody, @Path("id") id: Int = 6402): Observable<BaseEntity<Nothing>>

        /**
         * 7.4.3 编辑店员
         * /user/editUser/{userId}
         * 6403
         */
        @POST("turbot/app/{id}")
        fun editStaff(@Body body: RequestBody, @Path("id") id: Int = 6403): Observable<BaseEntity<Nothing>>

        /**
         * 7.4.4 删除店员
         * /user/deleteUser/{userId}
         * 6404
         */
        @POST("turbot/app/{id}")
        fun deleteStaff(@Path("id") id: Int = 6404, @Body body: RequestBody): Observable<BaseEntity<Nothing>>
    }

    /**
     * @author H
     * @createTime 2018/12/27 11:22
     * @description 经营数据
     */
    interface StatisticsService {

        /**
         * 3.1.1 获得经营数据
         * 3001
         * /statistics/getStatisticalAmount
         */
        @POST("turbot/app/{id}")
        fun getBusinessStatistics(@Body body: RequestBody, @Path("id") id: Int = 3001): Observable<BaseEntity<StatisticsEntity>>

        /**
         * 3.1.2 获得菜品销量数据
         * 3002
         * /statistics/getStatisticalDishes
         */
        @POST("turbot/app/{id}")
        fun getDishStatistics(@Body body: RequestBody, @Path("id") id: Int = 3002): Observable<BaseEntity<List<SoldDishEntity>>>

    }

    interface SettingService {
        /**
         * 7.5.3.1 检测版本
         * /version/checkForUpdate
         *
         * 1 android
         */
        @POST("turbot/app/{id}")
        fun checkVersion(@Body body: RequestBody, @Path("id") id: Int = 6504): Observable<BaseEntity<VersionEntity>>

        /**
         * 7.5.2 帮助与反馈设置
         * /user/feeBack/{restaurantId}
         * 6503
         */
        @POST("turbot/app/{id}")
        fun giveFeedback(@Body body: RequestBody, @Path("id") id: Int = 6503): Observable<BaseEntity<Nothing>>

    }

    interface UploadService {
        @POST("files/upload")
        fun uploadDishIcon(@Body file: RequestBody/*MultipartBody也可以*/): Observable<UploadEntity>

    }

    /**
     * @author H
     * @createDate 2019/1/18 9:43
     * @description 营销界面
     */
    interface MarketingService {

        /**
         * 5.1 获取营销首页
         * 4001
         */
        @GET("turbot/app/{id}")
        fun getMarketingPage(@Path("id") id: Int = 4001, @Query("restaurantId") restaurantId: Int): Observable<BaseEntity<MarketingHomeEntity>>

        /**
         * 5.2.1 获取特价菜列表
         */
        @GET("turbot/app/{id}")
        fun getSpecialDishes(@Path("id") id: Int = 4101, @Query("restaurantId") restaurantId: Int): Observable<BaseEntity<List<SpecialDishEntity>>>

        /**
         * 5.2.2 保存特价菜
         */
        @POST("turbot/app/{id}")
        fun saveSpecialDishes(@Path("id") id: Int = 4102, @Body body: RequestBody): Observable<BaseEntity<Nothing>>

        /**
         * 5.2.3 删除特价菜
         */
        @POST("turbot/app/{id}")
        fun deleteSpecialDish(@Path("id") id: Int = 4103, @Body body: RequestBody): Observable<BaseEntity<Nothing>>

        /**
         * 5.3.1 单品折扣列表
         * FIXME: 2019/1/18 返回与界面不符
         */
        @GET("turbot/app/{id}")
        fun getDiscountDishes(@Path("id") id: Int = 4201, @Query("restaurantId") restaurantId: Int): Observable<BaseEntity<DiscountDishEntity>>

        /**
         * 5.3.3 添加菜品折扣
         * 应该废弃
         */
        @POST("turbot/app/{id}")
        fun addDiscountDish(@Path("id") id: Int = 4204, @Body body: RequestBody): Observable<BaseEntity<Nothing>>

        /**
         * 5.3.4 编辑菜品折扣
         */
        @POST("turbot/app/{id}")
        fun editDiscountDish(@Path("id") id: Int = 4205, @Body body: RequestBody): Observable<BaseEntity<Nothing>>

        /**
         * 5.3.5 删除折扣单中的菜品(应该废弃)
         */
        @POST("turbot/app/{id}")
        fun deleteDiscountDish(@Path("id") id: Int = 4206, @Body body: RequestBody): Observable<BaseEntity<Nothing>>

        /**
         * 5.3.2 保存单个折扣单
         * FIXME: 2019/1/18 上传参数与界面不符,DiscountDishRequest
         */
        @POST("turbot/app/{id}")
        fun saveDiscountInfo(@Path("id") id: Int = 4203, @Body body: RequestBody): Observable<BaseEntity<Nothing>>

        /**
         * 5.3.6 删除菜品折扣单
         */
        @POST("turbot/app/{id}")
        fun deleteDiscountInfo(@Path("id") id: Int = 4207, @Body body: RequestBody): Observable<BaseEntity<Nothing>>

        /**
         * 5.4.1 获取闲时折扣信息
         * fixme: 返回实体类更改
         */
        @GET("turbot/app/{id}")
        fun getFreeTimeDiscount(@Path("id") id: Int = 4301, @Query("restaurantId") restaurantId: Int): Observable<BaseEntity<FreeTimeDiscountDetailEntity>>

        /**
         * 5.4.4 删除闲时折扣
         */
        @POST("turbot/app/{id}")
        fun deleteFreeTimeDiscount(@Path("id") id: Int = 4304, @Body body: RequestBody): Observable<BaseEntity<Nothing>>

        /**
         * 5.4.2 获取闲时折扣详情
         */
        @GET("turbot/app/{id}")
        fun getFreeTimeDiscountDetail(@Path("id") id: Int = 4302, @Query("id") restaurantId: Int): Observable<BaseEntity<FreeTimeDiscountDetailEntity>>

        /**
         * 5.4.3 保存闲时折扣详情
         */
        @POST("turbot/app/{id}")
        fun saveFreeTimeDiscountDetail(@Path("id") id: Int = 4303, @Body body: RequestBody): Observable<BaseEntity<Nothing>>

        /**
         * 5.5.1 分享优惠券
         */
        @GET("turbot/app/{id}")
        fun getShareDiscount(@Path("id") id: Int = 4401, @Query("restaurantId") restaurantId: Int): Observable<BaseEntity<ShareDiscountEntity>>

        /**
         * 5.5.2 保存分享活动
         */
        @POST("turbot/app/{id}")
        fun saveShareDiscount(@Path("id") id: Int = 4402, @Body body: RequestBody): Observable<BaseEntity<Nothing>>

        /**
         * 5.6.1 获取满减金额信息
         */
        @GET("turbot/app/{id}")
        fun getFullReduction(@Path("id") id: Int = 4501, @Query("restaurantId") restaurantId: Int): Observable<BaseEntity<FullReductionEntity>>

        /**
         * 5.6.2 保存满减金额信息
         */
        @POST("turbot/app/{id}")
        fun saveFullReduction(@Path("id") id: Int = 4502, @Body body: RequestBody): Observable<BaseEntity<Nothing>>

        /**
         * 5.7.1 提前买单折扣信息
         */
        @GET("turbot/app/{id}")
        fun getEarlyPayDiscount(@Path("id") id: Int = 4601, @Query("restaurantId") restaurantId: Int): Observable<BaseEntity<EarlyPayDiscountEntity>>

        /**
         * 5.7.2 保存提前买单信息
         * @return Observable<BaseEntity<Nothing>>
         */
        @POST("turbot/app/{id}")
        fun saveEarlyPayDiscount(@Path("id") id: Int = 4602, @Body body: RequestBody): Observable<BaseEntity<Nothing>>

    }

}